package com.zzyl.controller;


import com.zzyl.base.ResponseResult;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级管理")
public class NursingLevelController extends BaseController{

    @Autowired
    private NursingLevelService nursingLevelService;

    /**
     * 获取所有护理等级
     * @return
     */
    @ApiOperation(value = "获取所有护理等级")
    @GetMapping("/listAll")
    public ResponseResult<List<NursingLevel>> list() {
        return success(nursingLevelService.list()) ;
    }

    /**
     * 新增护理等级
     * @param nursingLevel
     * @return
     */
    @ApiOperation(value = "添加护理等级")
    @PostMapping("/insert")
    public ResponseResult add(@RequestBody NursingLevel nursingLevel) {
        nursingLevelService.insert(nursingLevel);
        return success();
    }

    /**
     * 条件分页查询
     * @param pageNum
     * @param pageSize
     * @param name
     * @param status
     * @return
     */
    @ApiOperation(value = "条件分页查询")
    @GetMapping("/listByPage")
    public ResponseResult<List<NursingLevel>> selectByPage(Integer pageNum, Integer pageSize, String name, Byte status ) {
            return success(nursingLevelService.getByPage(pageNum,pageSize,name,status));
    }

    /**
     * 根据id查询护理等级
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id查询护理等级")
    @GetMapping("/{id}")
    public ResponseResult<NursingLevel> selectById(@PathVariable Long id) {
        return success(nursingLevelService.selectById(id));
    }

    /**
     * 修改护理等级
     * @param nursingLevel
     * @return
     */
    @ApiOperation(value = "修改护理等级")
    @PutMapping("/update")
    public ResponseResult update(@RequestBody NursingLevel nursingLevel) {
        nursingLevelService.update(nursingLevel);
        return success();
    }
    /**
     * 删除护理等级
     * @param id
     * @return
     */
    @ApiOperation(value = "删除护理等级")
    @DeleteMapping("/delete/{id}")
    public ResponseResult delete(@PathVariable Long id) {
        nursingLevelService.deleteById(id);
        return success();
    }


    /**
     * 启用 禁用护理等级
     * @param id
     * @param status
     * @return
     */
    @ApiOperation(value = "启用禁用护理等级")
    @PutMapping("/{id}/status/{status}")
    public ResponseResult updateStatus(@PathVariable Long id, @PathVariable Byte status) {
        nursingLevelService.updateStatus(id, status);
        return success();
    }



}